import {
	defineStore
} from 'pinia';
const system = defineStore('system', {
	state: () => ({
		CustomBar: 0,
		Custom: null,
		StatusBar: 0
	}),
	actions: {
		initSystem() {
			var that = this;
			if (this.CustomBar == 0 || this.StatusBar == 0) {
				uni.getSystemInfo({
					success: function(e) {
						//console.log(e)
						// #ifndef MP
						that.StatusBar = e.statusBarHeight;
						if (e.platform == 'android') {
							that.CustomBar = e.statusBarHeight + 50;
						} else {
							that.CustomBar = e.statusBarHeight + 45;
						};
						// #endif
						// #ifdef MP-WEIXIN
						that.StatusBar = e.statusBarHeight;
						let custom = wx.getMenuButtonBoundingClientRect()
						that.Custom = custom;
						//console.log(custom)
						that.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
						// #endif		
						// #ifdef MP-ALIPAY
						that.StatusBar = e.statusBarHeight;
						that.CustomBar = e.statusBarHeight + e.titleBarHeight;
						// #endif
						//console.log(that.CustomBar)
					}
				})
			}
		}
	}
})
export default system
